**********************************************************************************************************
* Do-file to replicate analyses in 'The electoral returns of party-sponsored citizen legislative initiatives'
* January 2024
**********************************************************************************************************

*+++++++++++++++++++++++++++++++PREAMBLE+++++++++++++++++++++++++++++++++++++* 

cd "" // Set path to directory where replication package was unzipped

*******************
* ADOs
*******************
*ssc install estout, replace 
*ssc install ebalance, replace
*ssc install drdid, replace


*-------------------------------------------------------------------------------
* ANALYSES IN THE MAIN TEXT
*-------------------------------------------------------------------------------

*** Table 1: The evolution of the USR vote in treated localities vs. elsewhere
use "electoral returns.dta"
ebalance Treated Branch_CI IDUL18_std Urban lnDist200 lnPopulation18, toler(.3)
reshape long P_USR, i(SIRUTA) j(year)
gen treatment=1 if Treated==1 & year==2019
replace treatment=1 if Treated==1 & year==2020
replace treatment=0 if Treated==1 & year==2016
replace treatment=0 if Treated==0
xtset SIRUTA year
xtreg P_USR treatment i.year if year<2020, fe vce (cl SIRUTA)
estimates store m1, title(Model 1)
xtreg P_USR treatment i.year, fe vce (cl SIRUTA)
estimates store m2, title(Model 2)
xtreg P_USR treatment i.year [pw=_webal] if year<2020, fe vce (cl SIRUTA)
estimates store m3, title(Model 3)
xtreg P_USR treatment i.year [pw=_webal], fe vce (cl SIRUTA)
estimates store m4, title(Model 4)
estout m*, cells(b(star fmt(%9.3f)) se(par)) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2 N)

*** Table 2: The share of signatures for the initiative and the USR vote
use "electoral returns.dta", clear
regress P_USR2019 Sign_Percent P_USR2016 Branch_EP Urban lnPopulation18 lnDist200, cluster(County)
estimates store m1, title(Model 1)
regress P_USR2019 Sign_Percent P_USR2016 Branch_EP Urban lnPopulation18 lnDist200 IDUL18_std, cluster(County)
estimates store m2, title(Model 2)
regress P_USR2020 Sign_Percent P_USR2019 P_USR2016 Branch_2020 Urban lnPopulation18 lnDist200, cluster(County)
estimates store m3, title(Model 3)
regress P_USR2020 Sign_Percent P_USR2019 P_USR2016 Branch_2020 IDUL18_std Urban lnPopulation18 lnDist200, cluster(County)
estimates store m4, title(Model 4)
estout m*, cells(b(star fmt(%9.3f)) se(par)) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2 N)

*** Figure 2: Substantive effect of the share of citizens signing the petition
use "electoral returns.dta", clear
* Left panel of the figure (2019)
regress P_USR2019 P_USR2016 Sign_Percent Branch_EP Urban lnPopulation18 lnDist200 IDUL18_std, cluster(County)
gen sample=e(sample)
generate where = 0 if sample==1
generate pipe = "|" if sample==1
regress P_USR2019 P_USR2016 Sign_Percent Branch_EP Urban lnPopulation18 lnDist200 IDUL18_std, cluster(County)
margins, at(Sign_Percent=(0 5 10 15 20 25))
marginsplot, level(95) recast(line) recastci(rline) name(graph1, replace) addplot (scatter where Sign_Percent if Sign_Percent!=., ms(none) mlabel(pipe) mlabpos(0)) legend(off) xlabel(0(5)30) scheme(plotplain) ytitle("Predicted USR vote share in locality at 2019 elections") aspectratio(1)
graph save graph2019
* Right panel of the figure (2020)
drop where pipe
regress P_USR2020 P_USR2019 P_USR2016 Sign_Percent Branch_2020 IDUL18_std Urban lnPopulation18 lnDist200, cluster(County)
gen sample2=e(sample)
generate where = 0 if sample2==1
generate pipe = "|" if sample2==1
regress P_USR2020 P_USR2019 P_USR2016 Sign_Percent Branch_2020 IDUL18_std Urban lnPopulation18 lnDist200, cluster(County)
margins, at(Sign_Percent=(0 5 10 15 20 25))
marginsplot, level(95) recast(line) recastci(rline) name(graph1, replace) addplot (scatter where Sign_Percent if Sign_Percent!=., ms(none) mlabel(pipe) mlabpos(0)) legend(off) xlabel(0(5)30) scheme(plotplain) ytitle("Predicted USR vote share in locality at 2020 elections") aspectratio(1)
graph save graph2020
graph combine graph2019.gph graph2020.gph, scheme(plotplain)



*-------------------------------------------------------------------------------
* ADDITIONAL ANALYSES IN THE APPENDIX
*-------------------------------------------------------------------------------

* Appendix 1: Supporting data and analyses
*** Table A1.1 Referendums on party-sponsored citizen initiatives in Europe (1990-2022)
use "European citizen initiatives", clear
list Country Date Title Party_name Opposition New_party Share if Party_sponsored=="Yes", table compress

*** Table A1.2: Results of the entropy balancing matching
use "electoral returns.dta", clear
ebalance Treated Branch_CI IDUL18_std Urban lnPopulation18 lnDist200, toler(.3)

*** Table A1.3: The evolution of turnout in treated localities vs. elsewhere
use "electoral returns.dta", clear
ebalance Treated Branch_CI IDUL18_std Urban lnPopulation18 lnDist200, toler(.3)
reshape long turnout, i(SIRUTA) j(year)
gen treatment=1 if Treated==1 & year==2019
replace treatment=1 if Treated==1 & year==2020
replace treatment=0 if Treated==1 & year==2016
replace treatment=0 if Treated==0
xtset SIRUTA year
xtreg turnout treatment i.year if year<2020, fe vce (cl SIRUTA)
estimates store m1, title(Model 1)
xtreg turnout treatment i.year, fe vce (cl SIRUTA)
estimates store m2, title(Model 2)
xtreg turnout treatment i.year [pw=_webal] if year<2020, fe vce (cl SIRUTA)
estimates store m3, title(Model 3)
xtreg turnout treatment i.year [pw=_webal], fe vce (cl SIRUTA)
estimates store m4, title(Model 4)
estout m*, cells(b(star fmt(%9.3f)) se(par)) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2 N)

*** Table A1.4: Party identifiers who signed a petition in 2018
use "ESS9ROe01.dta", clear
gen party_id=prtvtbro
replace party_id=prtclbro if prtvtbro>7 & prtclbro<5
replace party_id=6 if prtvtbro>7 & prtclbro==7
replace party_id=7 if prtvtbro>7 & prtclbro==5
replace party_id=7 if prtvtbro>7 & prtclbro==8
replace party_id=5 if prtvtbro>7 & prtclbro==6
lab def party 1 "PNL" 2 "PSD" 3 "PMP" 4 "UDMR" 5 "ALDE" 6 "USR" 7 "other" 
lab val party_id party
table party_id sgnptit [aw=anweight], statistic(percent, across(sgnptit))

* Appendix 2 Robustness checks

*** Table A2.1: The evolution of the USR vote (doubly-robust linear regressions)
*** 2019 models (M1 and M2)
use "electoral returns.dta", clear
reshape long P_USR, i(SIRUTA) j(year)
xtset SIRUTA year
drop if year>2019
drdid P_USR, ivar(SIRUTA) time(year) tr(Treated)  drimp
drdid P_USR Branch_CI IDUL18_std Urban lnDist200 lnPopulation18, ivar(SIRUTA) time(year) tr(Treated)  drimp
*** 2020 models (M3 and M4)
use "electoral returns.dta", clear
reshape long P_USR, i(SIRUTA) j(year)
xtset SIRUTA year
drop if year==2019
drdid P_USR, ivar(SIRUTA) time(year) tr(Treated)  drimp
drdid P_USR Branch_CI IDUL18_std Urban lnDist200 lnPopulation18, ivar(SIRUTA) time(year) tr(Treated)  drimp

*** Table A2.2: The evolution of the USR vote in treated localities vs. elsewhere, with additional covariate matching  
use "electoral returns.dta", clear
ebalance Treated Branch_CI VOL_mean Anticorruption IDUL18_std Urban lnDist200 lnPopulation18, toler(.3)
reshape long P_USR, i(SIRUTA) j(year)
gen treatment=1 if Treated==1 & year==2019
replace treatment=1 if Treated==1 & year==2020
replace treatment=0 if Treated==1 & year==2016
replace treatment=0 if Treated==0
xtset SIRUTA year
xtreg P_USR treatment i.year [pw=_webal] if year<2020, fe vce (cl SIRUTA)
estimates store m3, title(Model 3)
xtreg P_USR treatment i.year [pw=_webal], fe vce (cl SIRUTA)
estimates store m4, title(Model 4)
estout m3 m4, cells(b(star fmt(%9.3f)) se(par)) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2 N)

*** Table A2.3: Share of signatures for the initiative and USR vote, controlling for anti-corruption action and electoral volatility
use "electoral returns.dta", clear
regress P_USR2019 Sign_Percent P_USR2016 Branch_EP Urban lnPopulation18 lnDist200 Anticorruption VOL_mean, cluster(County)
estimates store m1, title(Model 1)
regress P_USR2019 Sign_Percent P_USR2016 Branch_EP Urban lnPopulation18 lnDist200 IDUL18_std Anticorruption VOL_mean, cluster(County)
estimates store m2, title(Model 2)
regress P_USR2020 Sign_Percent P_USR2016 P_USR2019 Branch_2020 Urban lnPopulation18 lnDist200 Anticorruption VOL_mean, cluster(County)
estimates store m3, title(Model 3)
regress P_USR2020 Sign_Percent P_USR2016 P_USR2019 Branch_2020 IDUL18_std Urban lnPopulation18 lnDist200 Anticorruption VOL_mean, cluster(County)
estimates store m4, title(Model 4)
estout m*, cells(b(star fmt(%9.3f)) se(par)) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2 N)
